//
//  InformationLeftImageCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/4/22.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "InformationLeftImageCell.h"

@implementation InformationLeftImageCell{
    QXLable     *labTitle;
    QXLable     *labTime;
    UIImageView *imageV;
    UIImageView *imageComments;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        imageV=[[UIImageView alloc]init];
        [self.contentView addSubview:imageV];
        [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).with.offset(-10);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(105, 75));
        }];
        
        labTitle=[[QXLable alloc]initTitle];
        labTitle.numberOfLines=0;
        [labTitle setSpace:5];
        [self.contentView addSubview:labTitle];
        [labTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).with.offset(11);
            make.left.equalTo(self.contentView).with.offset(10);
            make.right.equalTo(imageV.mas_left).with.offset(-17);
        }];
        
        labTime=[[QXLable alloc]initWithFount:13];
        [self.contentView addSubview:labTime];
        [labTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(labTitle);
            make.bottom.equalTo(self.contentView).with.offset(-12);
            make.top.equalTo(labTitle.mas_bottom).with.offset(20);
        }];
        
//        imageComments=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"comments"]];
//        [self.contentView addSubview:imageComments];
//        [imageComments mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(labTime.mas_right);
//            make.centerY.equalTo(labTime);
//            make.size.mas_equalTo(imageComments.image.size);
//        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setModel:(NewsModel *)model{
    _model=model;
    labTitle.text=model.Title;
    labTime.text=[NSString stringWithFormat:@"%@  %@",NEW_APP_NAME,model.ReleaseTime];
    if (model.ThumbList.count>0) {
        NSString *url=model.ThumbList[0];
        [imageV sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"small_loding"]];
    }
    imageComments.hidden=NO;
}

- (void)setAdModel:(AdvertisingModel *)adModel{
    _adModel=adModel;
    if ([adModel.Title containsString:@"【"]) {
        labTitle.attributedText = [NSAttributedString tg_imageTextWithTitle:adModel.Title];
        
    } else {
        labTitle.text=adModel.Title;
    }
    
    labTime.text=[NSString stringWithFormat:@"%@  %@",adModel.Company,adModel.SubTime];
    if (adModel.ThumbList.count>0) {
        NSString *url=adModel.ThumbList[0];
        [imageV sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"small_loding"]];
    }
    imageComments.hidden=YES;
}

@end
